package com.situ.mall.web.controller;

import com.situ.mall.common.service.IMemberService;
import com.situ.mall.common.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


@Controller
@RequestMapping("/")
public class IndexController {


    @Autowired
    private IProductService productService;
    @Autowired
    private IMemberService memberService;

    @GetMapping("/")
    public String index(Model model){
        model.addAttribute("products",productService.indexProducts(1));//传一级分类id
        model.addAttribute("products2",productService.indexProducts(9));
        model.addAttribute("products3",productService.indexProducts(2));
//        List<IndexProductVO> indexProductVOS = productService.indexProducts0();
//        Integer id1 = indexProductVOS.get(0).getId();
        //拿到三个商品的id判断是否重复，若重复则重新查
        model.addAttribute("products1111",productService.indexProducts0());
        model.addAttribute("products2222",productService.indexProducts0());
        model.addAttribute("products3333",productService.indexProducts0());

        model.addAttribute("avatar",memberService.getAvatar());

        //return字符串就是转发到页面
        return "index";
    }



}
